// TEST

// JFC
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.image.*;
import java.awt.event.*;
//GTGE
import com.golden.gamedev.object.sprite.AdvanceSprite;

public class Player extends AdvanceSprite {
	
	
    //tank info
	public double x = 100;
	public double y = 200;
	public int speed=3;
	private String p= "tank.png";
	private String PLAYERCENTER="center.png";
	
	//ammo info
		public int ammo=49;
		private String BULLET="bullet.png";
		int MAXAMMO=50;
	   		double center_x=0;
	   		double center_y=0;
	   		double bullet_x_origin=0;
	   		double bullet_y_origin=0;
	   		double[] bullet_x =  new double[50];
	   		double[] bullet_y =  new double[50];
	   		
public int rotate=0;


	public Player(){
		
	}
	public int rotate(){
	if (keyDown(KeyEvent.VK_LEFT)){
    	
    	rotate=rotate-5;
    	
    	if (rotate <= 0) rotate += 360;
    }
    
	}
    if (keyDown(KeyEvent.VK_RIGHT)) {
    	
    	rotate=rotate+5;

    	if (rotate >= 360) rotate =- 360;    
    }

    
    if (keyDown(KeyEvent.VK_UP)){
	
		y  =  y +  speed*Math.sin(( (rotate * Math.PI) )/180);
		
		x  =  x +  speed*Math.cos(( (rotate * Math.PI) )/180);
	
    }
   
    if (keyDown(KeyEvent.VK_DOWN)){
	   
			y  =  y -  (speed-2)*Math.sin(( (rotate * Math.PI) )/180);
	  
			x  =  x -  (speed-2)*Math.cos(( (rotate * Math.PI) )/180);
	
    }
    if (keyDown(KeyEvent.VK_SPACE)) {
    	
    	ammo--;
    	
    	sbullet[ammo].setX(bullet_x_origin);
    	sbullet[ammo].setY(bullet_y_origin);
    	
    	if (ammo<0) ammo=0;
    	
    	if (ammo>0){

    	bullet_x[ammo] =  bullet_x_origin + 50 * Math.cos(( (rotate * Math.PI) )/180);
    	bullet_y[ammo] =  bullet_y_origin + 50 * Math.sin(( (rotate * Math.PI) )/180); 
    
    	}
    	
   }
}
